﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{ 
    public class DevelopmentData : BaseFunction
    {


        public DevelopmentData()
            : base()
        {

        }

        public DevelopmentData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
        }
        public DataSet GetGABEW(DataSet dsTarget, DataRow dwABPOS)
        {

            string TableName = "GABEW";
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = " SELECT MIN(GABBUCHDAT) AS ACTENDDATE FROM GABEW WHERE GABBS = '13' "
                        + " AND GABAUFKRS =:GABAUFKRS  AND GABAUFLFD =:GABAUFLFD  AND GABAUFPOS = : GABAUFPOS "
                    ;
                orlReadCommand.Parameters.Add("GABAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                orlReadCommand.Parameters.Add("GABAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                orlReadCommand.Parameters.Add("GABAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = TableName;
                    dsResult.AcceptChanges();
                }
                foreach (DataRow rowGABEW in dsResult.Tables[TableName].Rows)
                {
                    dwABPOS["ACTENDDATE"] = rowGABEW["ACTENDDATE"];

                }
                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    if (dsTarget.Tables.Contains(TableName))
                    {
                        dsTarget.Tables[TableName].Clear();
                    }
                    dsTarget = ImportDataTable(dsTarget, dtTemp);
                }
                dsTarget.AcceptChanges();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }


    }
}